/**
 * @see https://umijs.org/docs/max/access#access
 * */
export default function access(initialState: { currentUser?: API.CurrentUser } | undefined) {
  const { currentUser } = initialState ?? {};
  return {
    canSystemAdmin: currentUser?.roleWeight === 0,
    canAdmin: currentUser?.roleWeight <= 1,
    canUser: currentUser?.roleWeight <= 2,
    canViewer: currentUser?.roleWeight === 3,
  };
}
